/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui.event;

import dto.TextEvent;
import java.text.SimpleDateFormat;
import java.util.ResourceBundle;
import javax.swing.JComponent;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import map.MapManager;
import org.jdesktop.swingx.mapviewer.GeoPosition;

/**
 * Panel that represents a textevent
 * 
 * @author Pascal
 */
public class TextEventPanel extends AbstractEventPanel {

    private JTextArea textArea;
    private TextEvent event;

    public TextEventPanel(TextEvent event) {
        if (event != null && textArea != null) {
            this.event = event;
            textArea.setText(event.getText());
            textArea.setLineWrap(true);
            textArea.setEditable(false);
            SimpleDateFormat formatter = new SimpleDateFormat("HH:mm");

            labelTime.setText(formatter.format(event.getEventDate().getTime()));
            labelName.setText(event.getEventName());
            paintEventOnMap();
        }
    }

    @Override
    public JComponent getContentComponent() {
        this.textArea = new JTextArea(20, 30);

        JScrollPane scrollPane = new JScrollPane(textArea);
        scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);



        return scrollPane;
    }

    @Override
    public String getContentLabelText() {
        return ResourceBundle.getBundle("gui/guilabels").getString("description");
    }

    @Override
    protected void paintEventOnMap() {

        MapManager mapManager = new MapManager(map);

        GeoPosition geoPos = new GeoPosition(event.getPos().getLanDeg(), event.getPos().getLonDeg());
        mapManager.drawTrack(event.getTrack().getTrackList());

        mapManager.paintGPSPoint(geoPos);
    }
}
